<template>
    <div>
        <div class="head">
            首页 &nbsp;/ &nbsp;
            <span>用户管理</span>
        </div>
        <div class="searchBox">
            <el-input placeholder="请输入搜索关键字" v-model="input" clearable></el-input>
            <button class="search">搜索</button>
            <button class="search" @click="AddPage">
                <i class="el-icon-circle-plus-outline"></i> 添加
            </button>
        </div>
        <el-table :data="admins" border style="width:1202px;">
            <el-table-column
                prop="_id"
                label="用户编号"
                width="240"
                header-row-style="text-align: center;"
            ></el-table-column>
            <el-table-column prop="account" label="用户名" width="240"></el-table-column>
            <el-table-column prop="realname" label="真实姓名" width="240"></el-table-column>
            <el-table-column prop="telephone" label="联系方式" width="240"></el-table-column>
            <el-table-column label="操作" width="240">
              <template slot-scope="scope">
                    <button class="del" @click="delAdmin(scope.row._id)">删除</button>
              </template>
            </el-table-column>
        </el-table>
        <el-pagination background layout="prev, pager, next" :total="100"></el-pagination>

    </div>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapState, mapActions } = createNamespacedHelpers("usersModules");
export default {

    data() {
        return {
            input: '',

        }
    },
    computed: {
        ...mapState(['admins']),

    },
    methods: {
        ...mapActions(['asyncAdmins','asyncDelAdmins']),
        delAdmin(id){
           console.log(id);
           this.asyncDelAdmins({_id:id})
        },
        AddPage(){
            this.$router.push('/home/addAdmin')
        }


    },
    created() {
        this.asyncAdmins()

    }
}
</script>

<style scoped lang="scss">
.head {
    width: 1250px;
    height: 80px;
    border-bottom: 1px solid #ccc;
    text-align: left;
    line-height: 70px;
    font-size: 20px;
    color: #a4a4a4;
    span {
        color: black;
        font-weight: 600;
    }
}
.searchBox {
    width: 1250px;
    height: 100px;
    line-height: 100px;
    text-align: left;
}
.el-input {
    width: 300px;
    vertical-align: middle;
}
.search {
    width: 80px;
    height: 40px;
    background-color: #1891ff;
    font-size: 19px;
    color: #fff;
    border: none;
    vertical-align: middle;
    margin-right: 10px;
}
.el-table {
    text-align: center;
}
.del {
    width: 80px;
    height: 40px;
    background-color: #fe4d4e;
    margin-left: 70px;
    color: #fff;
    border: none;
}
</style>